<?php
//debug($taskok);
/*
 [0] => Array
        (
            [Task] => Array
                (
                    [id] => 1
                    [categories_id] => 1
                    [priorities_id] => 2
                    [types_id] => 1
                    [task] => what2Do
                    [bid] => 1
                    [jid] => 1492
                    [details] => 
                    [start] => 0000-00-00 00:00:00
                    [due] => 0000-00-00 00:00:00
                )

            [Category] => Array
                (
                    [id] => 1
                    [category] => pénzügy
                    [color] => ffc
                )

            [Priority] => Array
                (
                    [id] => 2
                    [priority] => 5
                    [description] => átlagos
                    [cssdef] => 
                )

            [Type] => Array
                (
                    [id] => 1
                    [type] => folyamatban
                )

            [Tag] => Array
                (
                )

*/
   $ical->create('Rrd - What2Do', 'Rrd What2Do feladatok', 'Europe/Budapest');
    
   foreach($taskok as $t){
		//$iCal->addEvent($start, $end=false, $summary, $description='', $extra=false)
		$ical->addEvent(
						$t['Task']['due'],
						date('Y-m-d H:i:s', strtotime('+1 hour', createTimeStamp($t['Task']['due']))),
						$t['Task']['task'],
						$t['Task']['details']."\n\n"/*,
						array(
								'UID'=>$Project['Project']['id'],
								'attach'=>$html->url('/Project/view/'.$Project['Project']['id'], true),
								'organizer'=>$Project['User']['username'],
								'location'=>$Project['location']
								)*/
						);
	}
	$ical->render();
	
function createTimeStamp($datetime){
   $year=substr($datetime,0,4);
   $month=substr($datetime,5,2);
   $day=substr($datetime,8,2);
   $hour=substr($datetime,11,2);
   $minute=substr($datetime,14,2);
   $second=substr($datetime,17,2);
	//print 'y:' . $year . ' m:' . $month . ' d:' . $day . ' h:' . $hour . ' i:' . $minute . ' s:' . $second . '<hr>';
   $timestamp=mktime($hour,$minute,$second,$month,$day, $year);
   return($timestamp);
}
?>